package com.nuc.thread.synchronizedTest;

import lombok.SneakyThrows;

/**
 * @Description n的值有可能为0 为正数 负数
 * @Author 诗酒趁年华
 * @Version V1.0.0
 * @Date 2021/5/9
 */
public class Test1 {
    static  int n = 0;
    @SneakyThrows
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 500; i++) {
                n = n+1;
            }
        },"t1");

        Thread t2 = new Thread(()->{
            for (int i = 0; i < 500; i++) {
                n = n-1;
            }
        },"t2");

        t1.start();
        t2.start();
        t1.join();
        t2.join();

        System.out.println("n的值"+n);

    }


}


